package cn.steel.mapper;

import cn.steel.domain.entity.SupplierRating;
import cn.steel.domain.vo.SupplierRatingVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface SupplierRatingMapper {
    void insertRating(SupplierRating rating);
    List<SupplierRating> findBySupplierId(Long supplierId);
    Double calculateAverageRating(Long supplierId);
    //插入
    //int insert(SupplierRating rating);
    //  更新
    int update(SupplierRating rating);
    //  根据订单ID和用户ID查询
    SupplierRating selectByOrderIdAndUserId(@Param("orderId") Long orderId, @Param("userId") Long userId);
    //  根据供应商ID查询
    List<SupplierRatingVo> selectBySupplierId(@Param("supplierId") Long supplierId);
    //  根据用户ID查询
    List<SupplierRatingVo> selectByUserId(@Param("userId") Long userId);
    //  根据订单ID查询
    SupplierRatingVo selectRatingDetail(@Param("orderId") Long orderId);
    //  判断订单是否存在
    boolean existsByOrderId(@Param("orderId") Long orderId);


    /**
     * 插入评价记录
     * @param supplierRating 评价实体
     */
    void insert(SupplierRating supplierRating);

    /**
     * 根据订单ID和供应商ID查找评价
     * @param orderId 订单ID
     * @param supplierId 供应商ID
     * @return 评价实体
     */
    SupplierRating findByOrderIdAndSupplierId(Long orderId, Long supplierId);

}